home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / visible.h < prev    next >
C/C++ Source or Header  |  1994-10-10  |  3KB  |  82 lines

  1. /* VISIBLE.H    Base class for any classes which may be put to
  2.    interface container (ObjectKit, ApplicationKit ...). ret is the flag,
  3.    it shows return or not after execution of this object.
  4.    exe() is the main function of object, it executes every time when
  5.    we choice object.
  6.  
  7.    Event contains information about type of event happened, coordinates of
  8.    mouse and so on. Menu and some other objects may replace events, for
  9.    example, pressing mouse on "exit" button may be replaced with keyboard
  10.    "EVENT_ESC".
  11.    action_type contains type of action of the last used object, or 0.
  12.    global_num contains number of menu item.
  13. */
  14.  
  15. #ifndef __VISIBLE_H_
  16. #define __VISIBLE_H_
  17.  
  18. #include "addevent.h"
  19. #include "action.h"
  20. #include "global.h"
  21.  
  22. enum where_mouse { MOUSE_OUT, MOUSE_IN };
  23.  
  24. enum ret_flags   { RET_OK = 1, RET_CANCEL = 2, RET_MOUSE = 4,
  25.            RET_ANY = 7, RET_TRANSFER = 8, RET_REMOVE = 16,
  26.            RET_SHOW = 32, RET_STACKED = 64 };
  27. // RET_ message transfer. See manual.
  28.  
  29. class Visible
  30.     {
  31.     protected:
  32.         int object_number;      // Number of base window in upper WManager.
  33.     int ret;          // Group of flags.
  34.     int pointTo;      // Object to pass control if OK EVENT handled.
  35.     int callFrom;     // Object to pass control if CANCEL EVENT handled.
  36.     int action_type;  // What to do.
  37.         int once;               // active?
  38.     public:
  39.     Visible()
  40.         {
  41.         once = ret = pointTo = callFrom
  42.              = action_type = object_number = 0;
  43.         }
  44.  
  45.     virtual ~Visible() { }
  46.         int active() { return once; }  // is it active
  47.         void set_active(int a) { once = a; }
  48.         int get_object_number() { return object_number; }
  49.         void set_object_number(int n) { object_number = n; }
  50.     virtual void repose(rect ) {} // For every object - analog of
  51.                                   // constructor. We call it after
  52.                       // resize of base window in container.
  53.     int isRet(int what) { return ret & what; }  // For example:
  54.                             // isRet(RET_OK)
  55.     int isPoint() { return pointTo; }
  56.     int isAct() { return action_type; }   // ACTION.H and ADAC*.H
  57.     int isCall() { return callFrom; }
  58.  
  59.     void assign(int pnt, int act_type)    // Links objects. Assign action
  60.         {                                 // to object.
  61.         pointTo = pnt;
  62.         action_type = act_type;
  63.         }
  64.  
  65.     void set_call(int call) { callFrom = call; }
  66.     void set_point(int p) { pointTo = p; }
  67.  
  68.     void set_ret(int r) { ret = r; }  // F.e.: set_ret(RET_OK | RET_CANCEL)
  69.  
  70.     virtual void exe(int act = 0) = 0;  // Main function - user interface.
  71.     virtual void show() = 0;
  72.         virtual void hide() {}
  73.     where_mouse mouse_in(loc l)    // Is the mouse inside this object.
  74.         {
  75.         return (where_mouse)(bound().contains(l));
  76.         }
  77.     virtual rect bound() = 0;  // Rectangle including this object
  78.     virtual void touch(int i = 0) {}    // Fill global_ or other structures with
  79.                    // class-specific data
  80.     };
  81.  
  82. #endif __VISIBLE_H_